package com.hb.znpt.adapter;

import android.widget.ImageView;

import androidx.annotation.NonNull;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.hb.znpt.R;
import com.hb.znpt.bean.LandBean;

/**
 * @Description: 描述
 * @Author: houbing
 * @CreateDate: 2021/12/17 14:59
 */
public class LandAdapter extends BaseQuickAdapter<LandBean, BaseViewHolder> {

    public LandAdapter() {
        super(R.layout.layout_item_land);
        addChildClickViewIds(R.id.photoBtn);
    }

    @Override
    protected void convert(@NonNull BaseViewHolder holder, LandBean bean) {
        holder.setText(R.id.tvName, bean.getZwmc());
        holder.setText(R.id.tvArea, bean.getZwmj() + "亩");
        holder.setText(R.id.tvShr, bean.getShr());
        holder.setText(R.id.tvReason, bean.getShyy());
        holder.setText(R.id.tvTime, bean.getShsj());
        ImageView imageView = holder.getView(R.id.imageView);
        if (bean.getSh().equals("0")) {
            holder.setVisible(R.id.photoBtn, true);
            holder.setGone(R.id.llSh, true);
        } else if (bean.getSh().equals("1")) {
            holder.setText(R.id.tvState, "待审核");
            holder.setVisible(R.id.llSh, true);
            holder.setGone(R.id.llReason, true);
            holder.setGone(R.id.llShr, true);
            holder.setGone(R.id.llShsj, true);
            holder.setGone(R.id.photoBtn, true);
            if (bean.getSc() != null) {
                Glide.with(getContext())
                        .load(bean.getSc().get(0).getPurl())
                        .error(R.drawable.ic_add_image)
                        .placeholder(R.drawable.ic_add_image)
                        .into(imageView);
                holder.setVisible(R.id.imageView, true);
            } else {
                holder.setGone(R.id.imageView, true);
            }
        } else if (bean.getSh().equals("2")) {
            holder.setText(R.id.tvState, "审核通过");
            holder.setVisible(R.id.llSh, true);
            holder.setVisible(R.id.llShr, true);
            holder.setVisible(R.id.llShsj, true);
            holder.setGone(R.id.llReason, true);
            holder.setGone(R.id.photoBtn, true);
            if (bean.getSc() != null) {
                Glide.with(getContext())
                        .load(bean.getSc().get(0).getPurl())
                        .error(R.drawable.ic_add_image)
                        .placeholder(R.drawable.ic_add_image)
                        .into(imageView);
                holder.setVisible(R.id.imageView, true);
            } else {
                holder.setGone(R.id.imageView, true);
            }
        } else {
            holder.setText(R.id.tvState, "审核未通过");
            holder.setText(R.id.tvReason, bean.getShyy());
            holder.setVisible(R.id.llSh, true);
            holder.setVisible(R.id.llShr, true);
            holder.setVisible(R.id.llShsj, true);
            holder.setVisible(R.id.llReason, true);
            holder.setVisible(R.id.photoBtn, true);
            if (bean.getSc() != null) {
                Glide.with(getContext())
                        .load(bean.getSc().get(0).getPurl())
                        .error(R.drawable.ic_add_image)
                        .placeholder(R.drawable.ic_add_image)
                        .into(imageView);
                holder.setVisible(R.id.imageView, true);
            } else {
                holder.setGone(R.id.imageView, true);
            }
        }
    }
}
